/**
 * 所有跟用户相关的接口
 */

import { ApiResponse, HttpListResp } from '@/types/http.d';
import { default as axios } from '@/utils/request';

/**
 * @interface loginParams -登录参数
 * @property {string} code -验证码
 * @property {string} username -用户名
 * @property {string} password -用户密码
 * @property {string} mobile -手机号
 */
interface LoginParams {
  code: string;
  username: string;
  password: string;
  mobile: string;
}

/**
 * @interface SendPhoneCodeParams -获取验证码参数
 */
interface SendPhoneCodeParams {
  mobile: string | number;
}

/**
 * 用户相关接口
 */
class UserService {
  // 注册登录
  static login<T = any>(data: any) {
    return axios<ApiResponse<T>>({
      url: '/seeker-web/v1/login',
      method: 'post',
      data,
    });
  }
  // 用户登出
  static logout<T = any>() {
    return axios<ApiResponse<T>>({
      url: '/seeker-web/v1/logout',
      method: 'post',
    });
  }
  // 获取图片验证码
  static getImageCode<T = any>(data?: any) {
    return axios<ApiResponse<T>>({
      url: '/seeker-web/v1/getImageCode',
      method: 'get',
      data,
    });
  }
  // 获取短信验证码
  static getMobileCode<T = any>(data: any) {
    return axios<ApiResponse<T>>({
      url: '/seeker-web/v1/getMobileCode',
      method: 'post',
      data,
    });
  }
  // 完善教育经历
  static improveEducationExperience<T = any>(data: any) {
    return axios<ApiResponse<T>>({
      url: '/seeker-web/v1/improveEducationExperience',
      method: 'post',
      data,
    });
  }
  // 完善工作经历与项目经历
  static improveProjectWorkExperience<T = any>(data: any) {
    return axios<ApiResponse<T>>({
      url: '/seeker-web/v1/improveProjectWorkExperience',
      method: 'post',
      data,
    });
  }
  // 填写求职意向
  static improvePurpose<T = any>(data: any) {
    return axios<ApiResponse<T>>({
      url: '/seeker-web/v1/improvePurpose',
      method: 'post',
      data,
    });
  }

  // 编辑求职意向
  static async editPurpose<T = any>(data: any) {
    return axios<ApiResponse<T>>({
      url: '/seeker-web/v1/editPurpose',
      method: 'post',
      data,
    });
  }
  // 完善基本信息
  static async improveSeekerInfo<T = any>(data: any) {
    return axios<ApiResponse<T>>({
      url: '/seeker-web/v1/improveSeekerInfo',
      method: 'post',
      data,
    });
  }
  // 用户头像上传
  static async uploadImage<T = any>(data: any) {
    return axios<ApiResponse<T>>({
      url: '/seeker-web/v1/uploadImage',
      method: 'post',
      data,
    });
  }

  // 求职进展已投递数据
  static selectSeekerSendResumeList<T = any>(params: any) {
    return axios<ApiResponse<HttpListResp<T>>>({
      url: '/seeker-web/v1/selectSeekerSendResumeList',
      method: 'get',
      params,
    });
  }

  // 求职者面试记录数据
  static selectSeekerInterviewList<T = any>(params: any) {
    return axios<ApiResponse<HttpListResp<T>>>({
      url: '/seeker-web/v1/selectSeekerInterviewList',
      method: 'get',
      params,
    });
  }
  // 收藏职位数据
  static selectSeekerCollectJobList<T = any>(params: any) {
    return axios<ApiResponse<T>>({
      url: '/seeker-web/v1/selectSeekerCollectJobList',
      method: 'get',
      params,
    });
  }

  static async selectSeekerForHomePage<T = any>() {
    return axios<ApiResponse<T>>({
      url: '/seeker-web/v1/selectSeekerForHomePage',
      method: 'get',
    });
  }

  static async selectSeekerImprove<T = any>() {
    return axios<ApiResponse<T>>({
      url: '/seeker-web/v1/selectSeekerImprove',
      method: 'get',
    });
  }

  // 求职者附件简历上传
  static uploadResume<T = any>(data: any) {
    console.log(data, '我是简历上传的data');
    return axios<ApiResponse<T>>({
      url: '/seeker-web/v1/uploadResume',
      method: 'post',
      headers: {
        'Content-Type': 'multipart/form-data',
      },
      data,
    });
  }

  // 删除工作经历
  static deleteWorkExperience<T = any>(id: string) {
    return axios<ApiResponse<T>>({
      url: `/seeker-web/v1/deleteWorkExperience/${id}`,
      method: 'post',
    });
  }

  // 根据记录ID删除项目
  static deleteProjectExperience<T = any>(id: string) {
    return axios<ApiResponse<T>>({
      url: `/seeker-web/v1/deleteProjectExperience/${id}`,
      method: 'post',
    });
  }

  // 根据记录ID删除教育经历
  static deleteEducationExperience<T = any>(id: string) {
    return axios<ApiResponse<T>>({
      url: `/seeker-web/v1/deleteEducationExperience/${id}`,
      method: 'post',
    });
  }

  // 求职者发起职位沟通(返回HrId)
  static async createJobIm<T = any>(jobId: string) {
    return axios<ApiResponse<T>>({
      url: `/seeker-web/v1/createJobIm/${jobId}`,
      method: 'post',
    });
  }

  // 求职者收藏职位
  static async collectJob<T = any>(params: any) {
    return axios<ApiResponse<T>>({
      url: `/seeker-web/v1/collectJob`,
      method: 'post',
      params,
    });
  }

  // 取消收藏职位
  static async cancelCollectJob<T = any>(params: any) {
    return axios<ApiResponse<T>>({
      url: `/seeker-web/v1/cancelCollectJob`,
      method: 'post',
      params,
    });
  }

  // 投递简历
  static async seekerSendResume<T = any>(params: any) {
    return axios<ApiResponse<T>>({
      url: `/seeker-web/v1/seekerSendResume`,
      method: 'post',
      params,
    });
  }
  // 一键投递简历
  // static async seekerSendResumes<T = any>(id: any) {
  //   return axios<ApiResponse<T>>({
  //     url: `/seeker-web/v1/seekerSendResume?jobId=${id}`,
  //     method: 'post',
  //   });
  // }

  // 一键投递简历1
  static async seekerSendResumes<T = any>(params: any) {
    return axios<ApiResponse<T>>({
      url: `/seeker-web/v1/seekerSendResume`,
      method: 'post',
      params,
    });
  }
  // 一键投递简历2
  static async seekerSendResumes2<T = any>(id: any) {
    return axios<ApiResponse<T>>({
      url: `/seeker-web/v1/seekerSendResume?jobId=${id}`,
      method: 'post',
    });
  }

  // 求职者主动发送手机号给HR
  static async sendPhoneProactive<T = any>(hrId: string) {
    return axios<ApiResponse<T>>({
      url: `/seeker-web/v1/sendPhoneProactive/${hrId}`,
      method: 'post',
    });
  }

  // 求职者主动发送附件简历给HR
  static async sendResumeProactive<T = any>(hrId: string) {
    return axios<ApiResponse<T>>({
      url: `/seeker-web/v1/sendResumeProactive/${hrId}`,
      method: 'post',
    });
  }

  // 获取短信验证码用于更换手机号
  static getMobileCodeForChange<T = any>(data: any) {
    return axios<ApiResponse<T>>({
      url: `/seeker-web/v1/getMobileCodeForChange`,
      method: 'post',
      data,
    });
  }
  // 更换手机号
  static changeMobile<T = any>(data: any) {
    return axios<ApiResponse<T>>({
      url: `/seeker-web/v1/changeMobile`,
      method: 'post',
      data,
    });
  }
  // 实名认证
  static identity<T = any>(data: any) {
    console.log(data);
    return axios<ApiResponse<T>>({
      url: `/seeker-web/v1/identity`,
      method: 'post',
      data,
    });
  }
}

export default UserService;
